package com.ytjj.qmyx.supplychain.mapper;

import com.ytjj.qmyx.supplychain.common.model.ProductComputeVO;
import com.ytjj.qmyx.supplychain.common.model.bill.response.OrderToBillResponse;
import com.ytjj.qmyx.supplychain.common.model.dto.AbroadOrderDto;
import com.ytjj.qmyx.supplychain.common.model.dto.AbroadReturnOrderDto;
import com.ytjj.qmyx.supplychain.common.model.dto.OrderToKafkaRecordDTO;
import com.ytjj.qmyx.supplychain.common.model.dto.OrdersFreightDto;
import com.ytjj.qmyx.supplychain.common.model.request.OrdersExpressRequest;
import com.ytjj.qmyx.supplychain.common.model.request.SalesStatisticalRequest;
import com.ytjj.qmyx.supplychain.common.model.request.SupplyChainImportOrdersExpressRequest;
import com.ytjj.qmyx.supplychain.common.model.request.SupplyChainOrderListRequest;
import com.ytjj.qmyx.supplychain.common.model.response.SupplyChainImportOrdersResponse;
import com.ytjj.qmyx.supplychain.common.model.response.SupplyChainOrderListResponse;
import com.ytjj.qmyx.supplychain.mapper.entity.YxOrders;
import com.ytjj.qmyx.supplychain.mapper.entity.YxOrdersPay;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.annotation.Order;
import tk.mybatis.mapper.common.Mapper;

import java.math.BigDecimal;
import java.util.List;

public interface OrdersMapper extends Mapper<YxOrders> {

    boolean updateOrders(@Param("list") List<OrdersExpressRequest> list);

    void updateOrderStatus(@Param("childOrderNo") String childOrderNo, @Param("status") Integer status);

    void updateOrderStatusByShopId(@Param("shopId") String shopId, @Param("childOrderNo") String childOrderNo, @Param("status") Integer status);

    void updateOrderStatusByShopId1(@Param("shopId") String shopId, @Param("childOrderNo") String childOrderNo);

    List<SupplyChainOrderListResponse> querySupplyChainOrderInfo(SupplyChainOrderListRequest request);

    /**
     * 查询导出数据订单数量
     * @param request
     * @return
     */
    Integer queryExportOrderCount(SupplyChainOrderListRequest request);

    /**
     *查询导出订单数据
     * @param request
     * @return
     */
    List<SupplyChainImportOrdersResponse> queryExportOrderList(SupplyChainOrderListRequest request);

    List<String> selectChildOrderNoByChildOrderNoList(@Param("list") List<String> childOrderNoList);

    ProductComputeVO getProductSalesByToday();

    ProductComputeVO getProductSalesByYesterday();

    List<ProductComputeVO> getStatisticalByTopCategory(SalesStatisticalRequest request);

    List<ProductComputeVO> getStatisticalByProduct(SalesStatisticalRequest request);

    ProductComputeVO getOrderCount();

    ProductComputeVO getOrderCountYesterday();

    List<AbroadOrderDto> selectOrderInfoByBankerId(@Param("bankerIds") List<Integer> bankerIds);

    List<String> selectWaitCEB622MessageList();

    List<AbroadReturnOrderDto> selectReturnAbroadOrderList(@Param("bankerIds") List<Integer> bankerIds);

    void updateOrdersByChildOrderNos(@Param("list") List<String> childOrderNoList);

    Integer updateFreightByChildOrderNo(@Param("childOrderNo") String childOrderNo, @Param("freight") BigDecimal freight);

    List<OrdersFreightDto> queryOrderFreightInfo(@Param("startTime") String startTime);

    /**
     * 该供应商特定时间内应付订单
     * @param bankerId
     * @param startTime
     * @param endTime
     * @return
     */
    List<OrderToBillResponse> selectBillOrder(@Param("bankerId") Integer bankerId, @Param("startTime") String startTime, @Param("endTime") String endTime);
    /**
     * 该供应商特定时间内应退订单
     * @param bankerId
     * @param startTime
     * @param endTime
     * @return
     */
    List<OrderToBillResponse> selectBillRefund(@Param("bankerId") Integer bankerId, @Param("startTime") String startTime, @Param("endTime") String endTime);

    void updateOrderReconciliationStatus(@Param("list") List<String> childOrderNos);

    void updateRefundReconciliationStatus(@Param("list") List<String> childOrderNos);

    List<YxOrders> selectByChildOrderNo(@Param("childOrderNos") List<String> childOrderNos);

    /**
     * 查询未发送kafka已完成的订单
     * @return
     */
    List<OrderToKafkaRecordDTO> selectOrdersToKafka(@Param("orderStatus") Integer orderStatus);

    /**
     * 查询n天后已签收但未完成的订单
     * @param day 天数
     * @return List<YxOrders>
     */
    List<YxOrders> selectUnFinishOrdersBetweenTime(Integer day);

    /**
     * 查询30天内申请售后,订单状态还是代发货的订单
     */
    List<String> queryReturnOrderBetweenTime(@Param("day") Integer day);

    int  updateOrderReturnGoodStatus(@Param("childOrderNos") List<String> childOrderNos);

    /**
     * 更新订单已发货
     * @param orderId 订单id
     * @param mark 0-更新为未完成 1-更新为已发货
     * @return int
     */
    int updateOrderFinishState(Integer orderId,Integer mark);
    
    /**
     * 更新订单表指定的列
     * @param
     * @return int
     */
    int updateOrderColumnById(YxOrders yxOrders);

    /**
     * 根据子订单号查询支付成功的支付信息
     */
    List<YxOrdersPay> queryAllByChildOrderNos(@Param("childOrderNos") List<String> childOrderNos);

}
